﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PreeRegisterModel;
using System.Data;
using PreeRegisterDAL;
using PreeRegisterBLL.Security;

namespace PreeRegisterBLL
{
    public class WorkCompareBLL
    {
        /// <summary>
        /// 排班号源比对
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static WorkCompareResponseModel GetWorkCompare(WorkCompareRequestModel request)
        {
            try
            {
                //查询排班数量统计
                WorkCompareResponseModel workCompareResponseModel = new PreeRegisterModel.WorkCompareResponseModel();

                if (request.workdate.Trim() == "")
                {
                    return null;
                }

                DataSet ds = WorkCompareDAL.GetWorkCompareInfo(request.workdate.Trim());

                //赋值排班比对实体
                List<DeptsWorkCompareModel> DeptsWorkCompareModel_list = new List<DeptsWorkCompareModel>();

                foreach (DataRow drWorkCompare in ds.Tables["WorkCompare"].Rows)
                {
                    DeptsWorkCompareModel deptsWorkCompareModel = new DeptsWorkCompareModel();
                    deptsWorkCompareModel.deptid = drWorkCompare["ideptid"].ToString();
                    deptsWorkCompareModel.whash = HashBase64.myHashBase64(drWorkCompare["strWorkPlanid"].ToString());
                    deptsWorkCompareModel.reshash = HashBase64.myHashBase64(drWorkCompare["strWorkPlanDetailid"].ToString());

                    DeptsWorkCompareModel_list.Add(deptsWorkCompareModel);
                }

                workCompareResponseModel.hospid = VariableBLL.HospitalId;
                workCompareResponseModel.depts = DeptsWorkCompareModel_list;

                //返回
                return workCompareResponseModel;
            }
            catch (Exception err)
            {

                throw;
            }
        }
    }
}
